Skip to content

feat(functions): add functions pull command#382

Merged
yardend-wix merged 15 commits intofeature/functions-commandsfrom
feature/functions-pull-command
Mar 12, 2026
Merged

feat(functions): add functions pull command#382
yardend-wix merged 15 commits intofeature/functions-commandsfrom
feature/functions-pull-command

Conversation

@yardend-wix
Copy link
Contributor

@yardend-wix yardend-wix commented Mar 8, 2026

Note

Description

This PR adds a functions pull command that downloads deployed backend functions from Base44 to the local project directory. It fetches all deployed functions (or a single named function) via the API and writes their source files and function.jsonc config to disk, skipping any functions whose local files already match the remote content.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added packages/cli/src/cli/commands/functions/pull.ts — CLI command that fetches remote functions and writes them locally, with support for pulling a single function by name via an optional [name] argument
  • Added packages/cli/src/core/resources/function/pull.ts — Core writeFunctions() logic that writes function.jsonc config and all source files per function, plus isFunctionUnchanged() to skip functions whose local files already match remote content (using isDeepStrictEqual)
  • Exported the new pull module and FunctionInfo type from the function resource index/schema
  • Registered the pull subcommand in packages/cli/src/cli/commands/functions/index.ts
  • Added packages/cli/tests/cli/functions_pull.spec.ts with 9 integration tests covering: no-functions, single-function pull, multi-file/nested structures, automations, unchanged-skip, error cases, and missing-project scenarios

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The pull command is idempotent: running it twice with no remote changes will report all functions as "unchanged" and write nothing. Nested file structures (e.g. src/lib/db.ts) are fully preserved. Automations are written to function.jsonc only when present, keeping configs minimal.


🤖 Generated by Claude | 2026-03-12 00:00 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.44-pr.382.bab01f6

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.44-pr.382.bab01f6"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.44-pr.382.bab01f6"
  }
}

Preview published to npm registry — try new features instantly!

yardend-wix and others added 4 commits March 9, 2026 11:30
Add a new `functions list` CLI command that lists all deployed functions
on the remote, showing automation counts. Restructure the functions
command group to use an index.ts that registers subcommands.

- Add ListFunctionsResponseSchema and FunctionInfo types to schema
- Add listDeployedFunctions API client function
- Create functions/list.ts command with automation count display
- Refactor functions/deploy.ts export to getDeployCommand
- Create functions/index.ts to register deploy + list subcommands
- Update program.ts to use getFunctionsCommand
- Add test mocks and 5 tests for the list command

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new `functions pull` CLI command that pulls deployed functions
from Base44 to local directories. Supports pulling all functions or
a specific one by name, with unchanged detection to skip up-to-date files.

- Add ListFunctionsResponseSchema and FunctionInfo types to schema
- Add listDeployedFunctions API client function
- Create core pull logic with writeFunctions and isFunctionUnchanged
- Create functions/pull.ts command with single-function support
- Refactor functions command group with index.ts
- Add test mocks and 6 tests for the pull command

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yardend-wix yardend-wix force-pushed the feature/functions-pull-command branch from 79fc81e to 01f45fa Compare March 9, 2026 09:46
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@kfirstri kfirstri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, i think we need to test it thoroughly since we have different kind of functions, with functions.json and without, with imports and other files, with nested folders..

yardend-wix and others added 5 commits March 10, 2026 15:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deleted Base44APIMock.ts (replaced by TestAPIServer.ts in main) and added
mockFunctionsList / mockFunctionsListError methods to TestAPIServer so the
functions-list tests work with the new test infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port mockFunctionsList, mockFunctionsListError, mockSingleFunctionDelete,
and mockSingleFunctionDeleteError from deleted Base44APIMock to TestAPIServer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These methods belong to the functions-delete branch, not functions-pull.
They were accidentally included during parallel merge conflict resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace JSON.stringify with isDeepStrictEqual from node:util for
  automations comparison, matching agents/connectors pattern
- Add tests for: multiple files with imports, nested folders,
  automations, and skip-unchanged behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kfirstri kfirstri moved this from Backlog to In review in CLI Development Mar 11, 2026
yardend-wix and others added 2 commits March 11, 2026 13:03
Replace FunctionAutomationInfoSchema (3-field summary) with the existing
full AutomationSchema so list response correctly parses all automation
fields. Add entity automation to test mock alongside scheduled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolves conflicts and picks up the schema fix (full AutomationSchema
instead of 3-field FunctionAutomationInfoSchema). Updates pull test to
mock both scheduled and entity automations with full field data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yardend-wix yardend-wix changed the base branch from main to feature/functions-list-command March 11, 2026 11:13
Base automatically changed from feature/functions-list-command to feature/functions-commands March 12, 2026 13:57
Combines pull, delete, and list subcommands in index.ts. Takes the
errorMessage fix for list.ts, keeps FunctionInfo export needed by pull,
and adds delete mock methods to TestAPIServer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yardend-wix yardend-wix merged commit 4748940 into feature/functions-commands Mar 12, 2026
3 checks passed
@yardend-wix yardend-wix deleted the feature/functions-pull-command branch March 12, 2026 14:12
@github-project-automation github-project-automation bot moved this from In review to Done in CLI Development Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants